package com.game.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

import com.game.modal.PointDetailInfo;
import com.game.modal.PointLog;


@Mapper
public interface PointLogMapper {
	@Insert("INSERT INTO point_log (\n" +
			"	send_id,\n" +
			"	send_name,\n" +
			"	room_id,\n" +
			"	point,\n" +
			"   point_remain,\n"+
			"	num,\n" +
			"	detail,\n" +
			"	create_time\n" +
			")\n" +
			"VALUES\n" +
			"	(\n" +
			"		#{sendId},\n" +
			"		#{sendName},\n" +
			"		#{roomId},\n" +
			"		#{point},\n" +
			"		#{remainPoint},\n"+
			"		#{num},\n" +
			"		#{detail},\n" +
			"		now()\n" +
			"	)")
	 @Options(useGeneratedKeys=true, keyProperty="id")
	int insert(PointLog pointlog);
	
	@Select("SELECT\n" +
			"	p.detail detail,\n" +
			"	p.num num,\n" +
			"	p.point point,\n" +
			"	p.send_name nickName,\n" +
			"	u.avatar_url avatarUrl\n" +
			"FROM\n" +
			"	point_log p\n" +
			"JOIN user u ON u.openid = p.send_id\n" +
			"WHERE\n" +
			"	p.id = #{id}\n"+
			"GROUP By p.id")
	PointDetailInfo selectByPramry(String id);
}
